﻿using Glue;
using Xunit;

namespace GlueTests.RelationsVerificationTests
{
    public class When_reading_exception
    {
        private readonly Mapping<DomainPerson, GuiPerson> mapping;

        public class DomainPerson
        {
            public int Id { get; private set; }
            public int Id2 { get; private set; }
        }

        public class GuiPerson
        {
            public int Id { get; set; }
            public int Id2 { get; set; }
        }

        public When_reading_exception()
        {
            mapping = new Mapping<DomainPerson, GuiPerson>();
        }

        [Fact]
        public void Should_include_the_typename()
        {
            
            try
            {
                mapping.GetRelationsVerification().AssertAllPropertiesRelated<GuiPerson>();
            }
            catch (GlueException e)
            {
                Assert.Contains("GuiPerson", e.Message);

            }
        }

        [Fact]
        public void Should_not_end_with_a_comma()
        {
            try
            {
                mapping.GetRelationsVerification().AssertAllPropertiesRelated<GuiPerson>();
            }
            catch (GlueException e)
            {
                Assert.False(e.Message.EndsWith(","));

            }
        }
    }
}
